//
//  NSDate+SF.h
//  SuperFormatter
//
//  Created by xxx on 14-6-21.
//  Copyright (c) 2014年 wtf. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, SFDateFormatBit) {
    SFDateFormatBitYear  = 0x0001,
    SFDateFormatBitMonth = (0x0001 << 1),
    SFDateFormatBitDay   = (0x0001 << 2),
    SFDateFormatBitHour  = (0x0001 << 3),
    SFDateFormatBitMin   = (0x0001 << 4),
    SFDateFormatBitSec   = (0x0001 << 5)
};

typedef NS_ENUM(NSInteger, SFDateFormats){
    SFDateFormatYM  = SFDateFormatBitYear | SFDateFormatBitMonth,
    SFDateFormatYMD = SFDateFormatBitYear | SFDateFormatBitMonth | SFDateFormatBitDay,
    SFDateFormatYMDhm = SFDateFormatYMD | SFDateFormatBitHour | SFDateFormatBitMin,
    SFDateFormatYMDhms = SFDateFormatYMDhm | SFDateFormatBitSec,
    
    SFDateFormatMD = SFDateFormatBitMonth | SFDateFormatBitDay,
    SFDateFormatMDhm = SFDateFormatMD | SFDateFormatBitHour | SFDateFormatBitMin,
    SFDateFormatMDhms = SFDateFormatMDhm | SFDateFormatBitSec,
    
    SFDateFormatDhm = SFDateFormatBitDay | SFDateFormatBitHour | SFDateFormatBitMin,
    SFDateFormatDhms = SFDateFormatDhm | SFDateFormatBitSec,
    
    SFDateFormathm = SFDateFormatBitHour | SFDateFormatBitMin,
    SFDateFormathms = SFDateFormathm | SFDateFormatBitSec,
    SFDateFormatms = SFDateFormatBitMin | SFDateFormatBitSec
};

#define SFSecondsPerDay 86400L

@interface NSDate (SF)

- (NSString *)dateStringWithFormat: (SFDateFormats)format;

// return nil if offset is too large
- (NSDate *)dateWithIncDays:(NSInteger)days;

- (NSDate *)zeroOfDate;

- (NSDateComponents *)agedForNow;

- (NSDate *)firstDayOfPreviousMonth;
- (NSDate *)firstDayOfNextMonth;

- (NSDate *)firstDayOfMonth;
- (NSDate *)lastDayOfMonth;

@end
